package day14;

import java.io.*;

/**
 * @author joker
 * @date 2022/4/24 0024 - 11:44
 */
public class Test02 {
    public static void main(String[] args) throws Exception {
//        FileInputStream fileInputStream = null;
//        FileOutputStream fileOutputStream = null;
//        BufferedInputStream bufferedInputStream = null;
//        BufferedOutputStream bufferedOutputStream = null;
        BufferedOutputStream bufferedOutputStream2=null;
        FileOutputStream fileOutputStream2=null;
        try (FileInputStream fileInputStream = new FileInputStream("hello.txt");
             BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
             FileOutputStream fileOutputStream = new FileOutputStream("hello2.txt");
             BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream)) {
            bufferedOutputStream2=bufferedOutputStream;
            fileOutputStream2=fileOutputStream;
            byte[] bytes = new byte[10];
            int len = 0;
            while ((len = bufferedInputStream.read(bytes)) > 0) {
                bufferedOutputStream.write(bytes, 0, len);
                bufferedOutputStream.flush();
            }
            fileOutputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
//            bufferedOutputStream2.write(new byte[]{97,98,99});
//            fileOutputStream2.write(new byte[]{97,98,99});
            bufferedOutputStream2.flush();
        }

    }
}
